<?php
namespace Admin\Controller;

class IndexController extends AdminBaseController
{
   public function main()
    {
        if(session('auid')==null){
            $this->display('index/login');
            exit();
        }
        $this->display('index/main');
    } 
    
    public function index(){
        if(session('auid')==null){
            $this->display('index/login');
            exit();
        } else {
            $this->display('index/index');
        }
    }
    
    public function login(){
        $account=I('username','');
        $paswd=I('password','');
        $cond['account']=$account;
        $cond['passwd']=md5($paswd);
        $admin=M('Admin')->where($cond)->select();
        if(empty($admin)){
            $this->display('index/login');
            exit();
        }
        session('auid',$admin[0]['id']);
        session('nickname',$admin[0]['nickname']);
        $this->display('index/main');
    }
}